{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## This notebook shows an application of kneed in selecting the optimal number of clusters from kmeans clustering algorithm."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Look at the K means tutorial posted [here](https://pythonprogramminglanguage.com/kmeans-elbow-method/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAEICAYAAACktLTqAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAARxElEQVR4nO3de2xkZ33G8efBa8BZAibCjbCzImmFnEaJ2qUDGy6liFAZlJSsEGqzVdoopVrRlquQIYao0AoKlREifyCqVcKl2rARCq5JKcJEgYjSkm1nY1RDthYBwu56N6xTcBLoABvn1z/m2Ovdxonn4jnj33w/UjRz3jln3l/OrB+P33N5HRECAOTytLILAAC0H+EOAAkR7gCQEOEOAAkR7gCQEOEOAAkR7gCQEOGOLcX2A7Zrth+1vWT7322/2fZT/lu2faHtsL1tk2vsSD/AkyHcsRX9QUScK+kFkj4i6T2Sbim3JKC7EO7YsiLi4Yi4Q9IfSbrO9qW2r7Q9a/sR20dtf2DNJt8oHpds/8z2S23/hu2v2f4f2w/ZvtX24MoGtt9je6H4S2He9hVF+9Ns32D7+8W2n7d93nr9bPKuAP4fwh1bXkT8h6Rjkn5X0s8l/amkQUlXSvoL27uLVV9ZPA5GxLMi4luSLOnDkoYl/aakHZI+IEm2RyW9RdKLi78UxiQ9ULzHWyXtlvR7xbY/lfSJJ+kH6CjCHVkcl3ReRNwdEXMR8XhE/JekA6oH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RSZ+3/SZJP5L0hxt6L24/AAD5cEAVABIi3AEgIcIdABIi3AEgIcIdABIi3AEgIcIdABL6Py8SFLiPtoU4AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZgcVb3/8fcnC5AQ9gQI2YZFkNUYJmHHBKKyCChryLgAInIFAVFxuchFrlcviChcFUVEQDEQ9l3AhyGACmTCGtZfQDAJGIJAIBDI9v39caqdnsksPcP0VPf05/U89UxtXfWtnpn+9jmn6hxFBGZmVrv65R2AmZnly4nAzKzGORGYmdU4JwIzsxrnRGBmVuOcCMzMapwTQY4knSnpD71wnjpJIWlAtnyPpGPLfd7e0JPXIulSST/oxutC0hY9EUM7x99D0rPlOn4b5yvr9XSXpO9KurhMx35R0uR2tnXr76KaOBGUkaTFRdNKSUuKlht6+FyXSlra6pyP9eQ5uqsoET3Sav3QLOYXSzxOryTOShMR90XEVuU4dqV+KZA0UdK84nUR8cOIqLhY+wIngjKKiCGFCfgHcEDRuivKcMpzis8ZER8pwzk+iMGStitangr8Pa9gzCxxIsjfapIul/S2pCcl1Rc2SNpE0rWSFkr6u6STevC8m0t6SNJbkm6UtH7ReQ/MYnkz+8a4dbb+aEk3F+33/yRdXbQ8V9LYDs75e+ALRcufBy4v3qG9a5a0D/Bd4Ig2SjtjJP0lew/vlDS0s2vJtn1U0sPZ664C1mgvcElbSJohaZGk17L9i03O3o83Jf1CkrLX9ZN0uqSXJL2a/a7XybZdJunr2fyIrNR0Qra8uaTXs9e3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ZUjqZBqocw/gJ0lDc7+N/cmtdvlTtKG2c/RpPaBP/bk8Qf05MEqlaRpwERgqKR5wH9FxG/zjQpI33A/BzyR1ccDfDcibssxJoDhwGXZHR39gOkRUTG3alagjYDr02cHA4A/RsSf8g3p374KXJFVw7wAHJ1zPMC/E+bHgS/nHUtBRDwo6RrgYWA58AiV09XEtZI2AJYBJ/R0o39N3D5qZmbtc9WQmVmNcyIwM6txTgRmZjXOicDMrMY5EZiZ1TgnArMeIKmu0nq3NSuVE4GZWY1zIjDrYZI2yzp5G593LGalqIkni816S9adw5XAURHxWN7xmJXCicCs5wwDbgQOzntwIbOucNWQWc9ZROq4bPe8AzHrCpcIzHrOUuAzwB2SFkdEj/YQaVYuTgRmPSgi3skG0LkrSwY35R2TWWfc+6iZWY1zG4GZWY1zIjAzq3FOBGZmNc6JwMysxjkRmJnVOCcCM7Ma50RgZlbj/j8beNDMQR1VWQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# clustering dataset\n",
    "# determine k using elbow method\n",
    " \n",
    "from sklearn.cluster import KMeans\n",
    "from sklearn import metrics\n",
    "from scipy.spatial.distance import cdist\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    " \n",
    "x1 = np.array([3, 1, 1, 2, 1, 6, 6, 6, 5, 6, 7, 8, 9, 8, 9, 9, 8])\n",
    "x2 = np.array([5, 4, 5, 6, 5, 8, 6, 7, 6, 7, 1, 2, 1, 2, 3, 2, 3])\n",
    " \n",
    "plt.plot()\n",
    "plt.xlim([0, 10])\n",
    "plt.ylim([0, 10])\n",
    "plt.title('Dataset')\n",
    "plt.scatter(x1, x2)\n",
    "plt.show()\n",
    " \n",
    "# create new plot and data\n",
    "plt.plot()\n",
    "X = np.array(list(zip(x1, x2))).reshape(len(x1), 2)\n",
    "colors = ['b', 'g', 'r']\n",
    "markers = ['o', 'v', 's']\n",
    " \n",
    "# k means determine k\n",
    "distortions = []\n",
    "K = range(1,10)\n",
    "for k in K:\n",
    "    kmeanModel = KMeans(n_clusters=k).fit(X)\n",
    "    kmeanModel.fit(X)\n",
    "    distortions.append(sum(np.min(cdist(X, kmeanModel.cluster_centers_, 'euclidean'), axis=1)) / X.shape[0])\n",
    "\n",
    "# Plot the elbow\n",
    "plt.plot(K, distortions, 'bx-')\n",
    "plt.xlabel('k')\n",
    "plt.ylabel('Distortion')\n",
    "plt.title('The Elbow Method showing the optimal k')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## focus on the second plot showing the distortion as a function of k clusters"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "range(1, 10) \n",
      " [3.4577032384495707, 1.7687413573405673, 0.8819889697423957, 0.7587138847606585, 0.6760729098960964, 0.6046508654312025, 0.5001764545028053, 0.41652236641410356, 0.3529411764705882]\n"
     ]
    }
   ],
   "source": [
    "print(K, '\\n', distortions)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Use kneed to determine best k"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('..')\n",
    "\n",
    "from kneed import KneeLocator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "kn = KneeLocator(list(K), distortions, S=1.0, curve='convex', direction='decreasing')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "kn.knee"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.LineCollection at 0x123aeb908>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deZwU1b3//9eHTdkiwkxUdo1xT0SD+xJQVCCIcUONoChc1J+JmpgYMTFel2uiP028xqAhaHALQlyB4J7BaNxYRMMiXCIqEJTFBQioqJ/vH6c609Mz3dMzdE31dL+fj0c9prqruupTPTP96XNOnXPM3RERkfLVIukAREQkWUoEIiJlTolARKTMKRGIiJQ5JQIRkTKnRCAiUuaUCBJkZv9tZvc1wXl6m5mbWavo8UwzGx33eZtCIa/FzCaa2XWNeJ2b2a6FiCHL8Y8ws8VxHb+O88V6PY1lZleY2YSYjv22mQ3Isq1RfxfNiRJBjMxsY9rypZltTnt8ZoHPNdHMPss45+uFPEdjpSWi1zKer4hifjvP4zRJ4iw27v68u+8ex7GL9UuBmfUzsxXpz7n79e5edLGWAiWCGLl7h9QCvAscn/bc/TGc8sb0c7r7vjGcY2u0M7N90h5/D1iWVDAiEigRJK+Nmd1jZhvMbIGZ9U1tMLOuZvaQma0xs2VmdlEBz/s1M3vVzNab2WNm1jntvEOjWD6KvjHuGT1/jplNS9vv/8zsz2mPl5tZnxznvBc4O+3xWcA96Ttku2YzGwhcAZxWR2mnl5n9PXoPnzKzivquJdq2n5nNjV43Gdg2W+BmtquZPWdmH5vZ2mj/dAOi9+MjM/udmVn0uhZm9nMze8fMVke/6+2ibXeb2aXRereo1HRh9PhrZvZB9Poa346jaowfm9kbUTyTzWzbtO2XmdkqM/uXmY3OVtVjZv8DHAHcFr2nt9V3PdHrzjWzR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x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.xlabel('k')\n",
    "plt.ylabel('Distortion')\n",
    "plt.title('The Elbow Method showing the optimal k')\n",
    "plt.plot(K, distortions, 'bx-')\n",
    "plt.vlines(kn.knee, plt.ylim()[0], plt.ylim()[1], linestyles='dashed')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "kneed",
   "language": "python",
   "name": "kneed"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
